package com.qfedu.edu.seckill.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常的工具类
 */
public class ExceptionUtils {

    /**
     * 将这个异常的站信息弄成字符串给返回来
     * @param exception
     * @return
     */
    public static String getExceptionStackMessage(Exception exception){
        //准备一个字符串的处理流
        StringWriter stringWriter = new StringWriter();
        //异常将信息打印的这个包装流
        PrintWriter printWriter = new PrintWriter(stringWriter);
        //将异常的站信息打印到这个打印流中去
        exception.printStackTrace(printWriter);
        //接下来只需要将目标中的数据弄成字符串就可以了
        String exceptionStackMessage = stringWriter.toString();
        //返回这个信息
        return exceptionStackMessage;
    }



}
